﻿using System;
using System.ComponentModel;
using System.Linq;
using ProjectEuler.Extensions;
using ProjectEuler.Linq;

namespace ProjectEuler.Problems
{
    [EulerProblem(20, 648)]
    [Description("Find the sum of digits in 100!")]
    internal sealed class Problem020 : EulerProblem
    {
        public override Object Solve()
        {
            var multiplier = new[] { 1 };

            var buffer = new Int32[200];
            buffer[buffer.Length - 1] = 1;

            for (; multiplier[0] <= 100; multiplier[0]++)
            {
                buffer = DecimalArithmetic.LongMultiplication(buffer, multiplier);
            }

            return buffer.Sum();
        }
    }
}
